import requests,time
from TS.common.login import TinyShop
from TS.common.thisisurl import url
class TinyShops:
    # def __init__(self):
    #     s = requests.session()
    #     self.s = s
    #     self.login()
    # def login(self):
    #     url_lgin = "http://192.168.4.226/TinyShop_v1.7/index.php?con=admin&act=check"
    #     data = {"name":"admin","password":"123456"}
    #     we = self.s.post(url=url_lgin,data=data)
    #     # cd =  we.text
    #     # if "退出" in cd:
    #     #     print("login pass")
    #     # else:
    #     #     print("login failed")
    def add(self,data):
        u=url()
        get_url=u.url()
        m=TinyShop()
        t,s=m.login({"name":"admin","password":"123456",'verifyCode': "aaaa"})
        url_add = get_url+"/index.php?con=goods&act=goods_save"
        # datas = {"category_id":"6","type_id":"4","name":"12345678","goods_no":"7899","unit":"%E4%BB%B6",
        #          "imgs%5B%5D":"data%2Fuploads%2F2014%2F05%2F04%2Ffc518b7ed40e2e80188331149c9a8d5e.jpg",
        #         "img":"data%2Fuploads%2F2014%2F05%2F04%2Ffc518b7ed40e2e80188331149c9a8d5e.jpg","pro_no":"7899",
        #         "store_nums":"123","warning_line":"23","weight":"1000","sell_price":"100","market_price":"90",
        #          "cost_price":"50","attr%5B1073741829%5D":"25","attr%5B1073741830%5D":"32"}

        re = s.post(url=url_add,data=data)
        cs = re.text

        return  cs
if  __name__ =="__main__":
    TinyShops()
    # q.add({"category_id":"6","type_id":"4","brand_id":"0","name":"12345678","tag_ids":"123",
    #         "goods_no":"7899", "point":"0","sort":"1", "unit":"%E4%BB%B6",
    #         "imgs%5B%5D":"data%2Fuploads%2F2014%2F05%2F04%2Ffc518b7ed40e2e80188331149c9a8d5e.jpg",
    #         "img":"data%2Fuploads%2F2014%2F05%2F04%2Ffc518b7ed40e2e80188331149c9a8d5e.jpg",
    #         "pro_no":"7899", "store_nums":"123","warning_line":"23","weight":"1000","sell_price":"100",
    #         "market_price":"90","cost_price":"50","attr%5B1073741829%5D":"25","attr%5B1073741830%5D":"32"})